package com.tjbklx1.redis.chap03;

import java.util.HashMap;
import java.util.Map;

import org.junit.Test;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.SortingParams;

import com.tjbklx1.redis.JedisUtil;

/**
 * 第三章的排序
 * @author tjbklx1
 * @date 2018-12-1
 */
public class App02Sort {

	@Test
	public void incr() {

		Jedis redis = JedisUtil.getJedis();
		String key = "sort_key";
		redis.del(key);

		redis.rpush(key, new String[]{"23","15","110","7"});
		System.out.println(redis.sort(key));
		System.out.println(redis.sort(key,new SortingParams().alpha()));
		System.out.println(redis.sort(key,new SortingParams().asc()));
		
	}
	
	@Test
	public void hash() {
		Jedis redis = JedisUtil.getJedis();
		String key = "hash_key";
		redis.del(key);
		Map<String, String> hash = new HashMap<String,String>();
		hash.put("k1", "1");
		hash.put("k2", "2");
		hash.put("k3", "3000");
		hash.put("k4", "40");
		hash.put("k5", "15");
		System.out.println("hmset "+redis.hmset(key, hash));
		
		System.out.println("hgetAll "+redis.hgetAll(key));
        //????
		System.out.println(redis.sort(key,new SortingParams().by("")));
		System.out.println(redis.sort(key,new SortingParams().by("")));
	}
		
}
